<template>
	<view>
		<uNavbar title="探索记录" bgColor="transparent"></uNavbar>
		<view class="tabss flex_ld">
			<view class="flex_c" v-for="(item,index) in list1" :key="index">
				<text @click="changeTabs(index)" :class="itemindex == index?'active':''">{{item}}</text>
			</view>
		</view>
		<view v-if="itemindex == 0">
			<view class="advent flex_Z">
				<view class="advent_top flex_ld" v-for="(item,index) in expeditionList" :key="item.id"
					@click="goDetails(item.id)">
					<view class="advent_top_l flex_Z">
						<text class="f30 c3">{{item.brand_activity.name}}</text>
						<text class="f24 c4">{{item.create_time}}</text>
					</view>
					<view class="advent_top_r flex_c">
						<text>遗迹详情 </text>
					</view>
				</view>
			</view>
			<noDatas :xxxList="expeditionList" :status="status"></noDatas>
		</view>
		<view v-if="itemindex == 1">
			<view class="advent flex_Z">
				<view class="advent_top flex_ld" v-for="(item,index) in digbabyList" :key="item.id" @click="goDetails(item.id)">
					<view class="advent_top_l flex_Z">
						<text class="f30 c3">{{item.name}}</text>
						<text class="f24 c4">{{item.create_time}}</text>
					</view>
					<view class="advent_state flex_ZC">
						<text class="f24 c5">{{item.status_desc}} </text>
						<text class="f24 c5">{{item.surplus_time}}</text>
					</view>
				</view>
				<!-- <view class="realm flex_c" >
					<text>挖宝详情</text>
				</view> -->
			</view>
			<noDatas :xxxList="digbabyList" :status="status"></noDatas>
		</view>
	</view>
</template>

<script>
	import {
		memberBrandActivity,
		memberDigList
	} from "../../api/secretRealm.js";
	export default {
		data() {
			return {
				page: 1,
				size: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				itemindex: 0,
				expeditionList: [],
				digbabyList: [],
				list1: ['激活记录', '探索记录'],
			}
		},
		onLoad(options) {
			if(options.index){
				this.itemindex=1
				this.digList()
			}
			this.initList()
			// this.digList()
		},
		methods: {
			// 初始化
			initList() {
				let data = {
					page: this.page,
				};
				memberBrandActivity(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						let list = res.data.data;
						this.expeditionList = this.page == 1 ? list : this.expeditionList.concat(list);
						console.log(this.expeditionList);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
				})
			},
			// 初始化
			digList() {
				let data = {
					page: this.page,
				};
				memberDigList(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						let list = res.data.data;
						this.digbabyList = this.page == 1 ? list : this.digbabyList.concat(list);
						console.log(this.digbabyList);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
				})
			},
			changeTabs(index) {
				console.log(index);
				this.itemindex = index
				if (index == 0) {
					this.initList()
				} else {
					this.digList()
				}
			},
			goDetails(id) {
				console.log(id);
				uni.navigateTo({
					url: '/pagesMy/secretRealm/adventureDetail?type=' + this.itemindex + '&id=' + id
				})
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			console.log('下拉刷新');
			let that = this;
			setTimeout(function() {
				that.page = 1
				if (that.itemindex == 0) {
					that.expeditionList = [],
						that.initList()
				} else {
					that.digbabyList = [],
						that.digList()
				}
			}, 800);
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				if (this.itemindex == 0) {
					this.initList()
				} else {
					this.digList()
				}
			}
		}
	}
</script>

<style scoped>
	.tabss {
		width: 92%;
		/* background: pink; */
		margin: 20rpx auto;
	}
	
	.tabss>view {
		padding: 20rpx 0;
		width: 50%;
		color: #A6A5AF;
	}
	
	.active {
		color: #333333 !important;
	}
	
	.advent {
		width: 690rpx;
		/* height: 234rpx; */
		background: #F2EFEC;
		border-radius: 16rpx;
		margin: 20rpx auto;
	}
	
	.advent_top {
		/* border-bottom: 1rpx solid #ffffff30; */
	}
	
	.advent_top_l {
		padding: 20rpx 30rpx;
	}
	
	.advent_top_l>text {
		margin: 10rpx 0;
	}
	
	.advent_top_r {
		margin-right: 30rpx;
		font-size: 24rpx;
		color: #ffffff;
		width: 124rpx;
		height: 52rpx;
		background: linear-gradient(274deg, #AB8E68, #D7BA93);
		border-radius: 232rpx 232rpx 232rpx 232rpx;
	}
	.advent_state{
		padding: 20rpx 30rpx;
	}
	.advent_state>text{
		margin-top: 10rpx;
	}

</style>